package de.dhbw.vs.permachat.client.activities.chatroomlist;

import com.google.web.bindery.event.shared.Event;
import com.google.web.bindery.event.shared.EventBus;

import de.dhbw.vs.permachat.client.dto.ChatRoom;

public class ChatRoomSelectedEvent extends Event<ChatRoomSelectedEvent.Handler> {

	public interface Handler {
		void onChatRoomSelected(ChatRoomSelectedEvent event);
	}

	private static final Type<ChatRoomSelectedEvent.Handler> TYPE = new Type<ChatRoomSelectedEvent.Handler>();
	private final ChatRoom chatRoom;

	public static void fire(EventBus eventBus, ChatRoom chatRoom) {
		eventBus.fireEvent(new ChatRoomSelectedEvent(chatRoom));
	}

	@Override
	public com.google.web.bindery.event.shared.Event.Type<Handler> getAssociatedType() {
		return TYPE;
	}

	protected ChatRoomSelectedEvent(ChatRoom chatRoom) {
		this.chatRoom = chatRoom;

	}

	@Override
	protected void dispatch(Handler handler) {
		handler.onChatRoomSelected(this);

	}

	public static Type<ChatRoomSelectedEvent.Handler> getType() {
		return TYPE;
	}

	public ChatRoom getChatRoom() {
		return chatRoom;
	}

}
